/*
 * #%L
 * java model
 * %%
 * Copyright (C) 2009 - 2011 Stefan Isele
 * %%
 * All Rights Reserved.
 * This program is dual-licensed under the GNU General Public license
 * or a commercial license.
 * You may select to use one or the other of these licenses.
 * To obtain a commercial license please contact Stefan Isele at www.stefan-isele.de
 * Any modifications to this file must keep this entire header intact.
 * Redistribution, except as permitted by the selected license, is prohibited.
 * #L%
 */
package com.prefabware.jmodel.expression;

import com.prefabware.jmodel.JField;
import com.prefabware.jmodel.JMethodDeclaration;
import com.prefabware.jmodel.code.JCodeOptions;

public class JVariableBase implements JVariable {
	public static JVariable create(JField field,
			JMethodDeclaration methodDeclaration) {
		JVariableDeclaration dcl = new JVariableDeclarationBase(false,
				field.getName(), field.getType(), field
						.getDeclaration().getTypeArguments());
		return new JVariableBase(dcl);
	}

	private JVariableDeclaration declaration;

	public JVariableDeclaration getDeclaration() {
		return declaration;
	}

	public JVariableBase(JVariableDeclaration declaration) {
		super();
		this.declaration = declaration;
	}

	/*
	 * the code for a variable is its name only
	 * there is no way nor need to reference it by a qualified name
	 */
	@Override
	public String asCode(JCodeOptions options) {
		return this.getDeclaration().getName();
	}
}
